package com.code.leetcode.before50;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/25 11:21
 */
public class The91 {
    public int numDecodings(String s) {
        int len = s.length();
        int[] dp = new int[len + 1];
        dp[0] = 1;
        dp[1] = 1;
        for (int i = 2; i < len + 1; i++) {
            if (s.charAt(i - 2) == '1' || s.charAt(i - 2) == '2' && s.charAt(i - 1) <= '6') {
                dp[i] += dp[i - 2];
            }
            if (s.charAt(i - 1) != 0) {
                dp[i] += dp[i - 1];
            }
        }
        return dp[len];
    }
}
